package com.lishe.lishe.lishe.module.mall.view;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Display;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import com.lishe.lishe.R;

/**
 * 商品参数弹窗
 * @author Bin
 */
public class GoodsParameterDialog extends Dialog implements View.OnClickListener {

	private Context context;
	private String mGoodsNo;
	private String mGoodsWeight;
	private String mGoodsBrand;

	public GoodsParameterDialog(Context context, String goodsno, String goodsweight, String goodsbrand) {
		super(context, R.style.SimpleBottomDialog);
		this.context = context;
		this.mGoodsNo = goodsno;
		this.mGoodsWeight = goodsweight;
		this.mGoodsBrand = goodsbrand;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dialog_goodsparameter);
		Window dialogWindow = this.getWindow();
		dialogWindow.setGravity(Gravity.BOTTOM);

		Display display = dialogWindow.getWindowManager().getDefaultDisplay();
		WindowManager.LayoutParams lp = dialogWindow.getAttributes();
		lp.width = display.getWidth();
		dialogWindow.setAttributes(lp);

		//设置点击Dialog外部任意区域关闭Dialog
		setCanceledOnTouchOutside(true);

		TextView mTvGoodsNo =  findViewById(R.id.goods_no);
		mTvGoodsNo.setText(mGoodsNo);
		TextView mTvGoodsWeight =  findViewById(R.id.goods_weight);
		mTvGoodsWeight.setText(mGoodsWeight);
		TextView mTvGoodsBrand =  findViewById(R.id.goods_brand);
		mTvGoodsBrand.setText(mGoodsBrand);

		findViewById(R.id.cancel).setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		dismiss();
	}
}
